/*
 * VHLeagueEternalStandingsTab.java
 * Created on 15 juil. 2009
 *
 * VirtualHockey Internet Platform
 * http://code.google.com/p/virtualhockey/
 *
 * Copyright (c) 2005-2009, Jens and Jan Janke (VirtualHockey Project)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
 */

package com.hockeo.vhweb.client.ui.tabs;

import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.hockeo.vhweb.client.VHMain;
import com.hockeo.vhweb.client.mvc.VHController;
import com.hockeo.vhweb.client.ui.base.VHTabItem;
import com.hockeo.vhweb.client.ui.widget.VHEternalStandingsGrid;
import com.hockeo.vhweb.client.utils.VHJsData;

/**
 * Tab that displays the eternal standings for a given contest element.
 *
 * @version $Id$
 * @author jjanke
 */
public class VHLeagueEternalStandingsTab extends VHTabItem
{
  private final VHJsData         d_league;
  private VHEternalStandingsGrid d_eternalStandingsGrid;

  /**
   * Sets a default title and icon style.
   *
   * @see GTabItem#GTabItem()
   */
  public VHLeagueEternalStandingsTab( VHController controller, VHJsData league )
  {
    super( controller, VHMain.getConstants().eternalStandings() );

    d_league = league;

    setIcon( VHMain.ICON_ETERNAL_STANDINGS );
  }

  @Override
  public void buildContent()
  {
    BorderLayoutData data;

    if ( isContentReady() )
      return;

    // standings
    //
    d_eternalStandingsGrid = new VHEternalStandingsGrid( getController(), d_league.getString( "regularSeasonElementId" ) );

    data = new BorderLayoutData( LayoutRegion.CENTER );
    data.setMargins( new Margins( 4, 4, 4, 4 ) );
    add( d_eternalStandingsGrid, data );

    // paging tool bar
    //
    data = new BorderLayoutData( LayoutRegion.SOUTH );
    data.setMargins( new Margins( 0, 4, 4, 4 ) );
    data.setSize( 30 );
    add( d_eternalStandingsGrid.getPagingToolBar(), data );

    super.buildContent();
  }
}
